<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('领养订单列表')" />
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <style>
        .float-right {
            float: right;
        }

        .detail-view {
            position: relative;
            z-index: 999;
        }

        .right-fixed-table-columns {
            width: 129px !important;
        }
    </style>
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>支付单号：</label>
                                <input type="text" name="orderNo"/>
                            </li>
                            <li>
                                <label>用户ID：</label>
                                <input type="text" name="orderUid"/>
                            </li>
                            <li>
                                <label>农场：</label>
                                <select type="text" name="orderFid" id="orderFid" class="form-control">
                                    <option value="">所有</option>
                                </select>
                            </li>
                            <li>
                                <label>餐厅：</label>
                                <select type="text" name="orderCid" id="orderCid" class="form-control">
                                <option value="">所有</option>
                                </select>
                            </li>

                            <li>
                                <label>领养状态：</label>
                                <select name="orderState" th:with="type=${@dict.getType('order_state')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary  btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning  btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: select2-js"/>
     <th:block th:include="include :: datetimepicker-js"/>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('wechat:WxOrder:edit')}]];
        var removeFlag = [[${@permission.hasPermi('wechat:WxOrder:remove')}]];
        var orderTypeDatas = [[${@dict.getType('order_type')}]];
        var orderStateDatas = [[${@dict.getType('order_state')}]];
        var poultrySlaughterStateDatas = [[${@dict.getType('poultry_slaughter_state')}]];
        var prefix = ctx + "wechat/WxOrder";

        $(function() {
            var options = {
                url: prefix + "/list",
                detailUrl: prefix + "/detail/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                fixedColumns: true,
                fixedNumber: 3,
                rightFixedColumns: true,
                rightFixedNumber: 1,
                modalName: "领养订单",
                columns: [
                    {
                        field: 'orderNo',
                        title: '支付单号',
                        sortable: false
                    },
                    {
                        field: 'orderType',
                        title: '领养方式',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(orderTypeDatas, value);
                        }
                    },
                {
                    field: 'orderId',
                    title: '编号',
                    visible: false,
                    sortable: false
                },
                {
                    field: 'userName',
                    title: '系统用户',
                    sortable: false,
                    formatter: function(value, row, index) {
                        return row.userName;
                    }
                },
                {
                    field: 'farmName',
                    title: '农场',
                    sortable: false,
                    formatter: function(value, row, index) {
                        return row.farmName+"("+row.farmWorkPhone+")";
                    }
                },
                {
                    field: 'orderPid',
                    title: '家禽',
                    sortable: false,
                    formatter: function(value, row, index) {
                        return row.wxPoultry.poultryName;
                    }
                },
                    {
                        field: 'wxPoultry.poultrySlaughterState',
                        title: '出栏状态',
                        align: 'center',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(poultrySlaughterStateDatas, value);
                        }
                    },
                {
                    field: 'orderName',
                    title: '联系人',
                    sortable: false
                },
                {
                    field: 'orderPhone',
                    title: '电话',
                    sortable: false
                },
                {
                    field: 'orderHost',
                    title: '邮寄地址',
                    sortable: false,
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'canteenName',
                    title: '餐厅',
                    sortable: false,
                    formatter: function(value, row, index) {
                       if(row.canteenName==null){
                           return "-";
                       }else {
                           return row.canteenName+"("+row.canteenPhone+")";
                       }
                    }
                },
                {
                    field: 'orderReviewKg',
                    title: '复核重量',
                    align: 'center',
                    sortable: false
                },
                {
                    field: 'orderLeaveKg',
                    title: '可加工重量',
                    align: 'center',
                    sortable: false
                },
                {
                    field: 'orderVideo',
                    title: '视频',
                    sortable: false,
                    formatter: function(value, row, index) {
                        if(value!=null){
                            return "<a href='"+value+"' target='_blank'>查看视频</a>";
                        }else {
                            return "-";
                        }
                    }
                },
                {
                    field: 'orderFee',
                    title: '已付定金',
                    align: 'center',
                    sortable: false
                },
                {
                    field: 'orderIsdayfee',
                    title: '已付饲料费',
                    align: 'center',
                    sortable: false
                },
                {
                    field: 'orderNodayfee',
                    title: '待付饲料费',
                    align: 'center',
                    sortable: false
                },
                {
                    field: 'orderState',
                    title: '领养状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(orderStateDatas, value);
                    }
                },
                {
                    field: 'orderTime',
                    title: '创建时间',
                    sortable: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="opendetil(\'' + row.orderId + '\',\'' + row.orderNo + '\')">详情</a> ');
                        actions.push('<a class="btn btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.orderId + '\')">编辑</a> ');
                        actions.push('<a class="btn btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.orderId + '\')">删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        $.operate.ajaxGet(ctx + "/wechat/WxFarm/listAjax", function (result) {
            if(result.data.length==0){
                $.modal.alertError("暂无农场")
            }
            var html = "";
            for (var i = 0; i < result.data.length; i++) {
                html += "<option value='" + result.data[i].farmId + "'>" + result.data[i].farmName + "</option>";
            }
            $("#orderFid").append(html);
        })

        $.operate.ajaxGet(ctx + "/wechat/WxCanteen/listAjax", function (result) {
            if(result.data.length==0){
                $.modal.alertError("暂无餐厅")
            }
            var html = "";
            for (var i = 0; i < result.data.length; i++) {
                html += "<option value='" + result.data[i].canteenId + "'>" + result.data[i].canteenName + "</option>";
            }
            $("#orderCid").append(html);
        })

        function opendetil(id, no) {
            $.modal.openFullDetail("订单详情-" + no, prefix + "/detail/" + id);
        }
    </script>
</body>
</html>
